<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <%%- title %>
  <link rel="stylesheet" type="text/css" href="https://cdn.bootcss.com/simplemde/1.11.2/simplemde.min.css" />
  <style>
    *{
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    html{
      font-size:16px;
    }
    body{
      font-size: 0.12rem
    }
    img{
      max-width: 100% !important;
      text-indent:0;
      display: block;
      margin: 10px auto;
    }
    a{
      text-decoration: none;
    }
    ol, ul{
      list-style: none;
    }
    .CodeMirror-scroll{
      min-height: 100px;
    }
    .CodeMirror{
      min-height: 100px;
    }
  </style>
  <style id="jss-style"><%%- jssStyle %></style>
  <script>
    ;(function(designWidth, maxWidth) {
      var doc = document,
      win = window,
      docEl = doc.documentElement,
      remStyle = document.createElement("style"),
      tid;

      function refreshRem() {
        var width = docEl.getBoundingClientRect().width;
        maxWidth = maxWidth || 540;
        width>maxWidth && (width=maxWidth);
        var rem = width * 16 / designWidth;
        remStyle.innerHTML = 'html{font-size:' + rem + 'px;}';
      }

      if (docEl.firstElementChild) {
        docEl.firstElementChild.appendChild(remStyle);
      } else {
        var wrap = doc.createElement("div");
        wrap.appendChild(remStyle);
        doc.write(wrap.innerHTML);
        wrap = null;
      }
      //要等 wiewport 设置好后才能执行 refreshRem，不然 refreshRem 会执行2次；
      refreshRem();

      win.addEventListener("resize", function() {
        clearTimeout(tid); //防止执行两次
        tid = setTimeout(refreshRem, 300);
      }, false);

      win.addEventListener("pageshow", function(e) {
        if (e.persisted) { // 浏览器后退的时候重新计算
          clearTimeout(tid);
          tid = setTimeout(refreshRem, 300);
        }
      }, false);

      // if (doc.readyState === "complete") {
      //   doc.body.style.fontSize = "16px";
      // } else {
      //   doc.addEventListener("DOMContentLoaded", function(e) {
      //     doc.body.style.fontSize = "16px";
      //   }, false);
      // }
    })(375, 750);
  </script>
</head>
<body>
<div id='app'><%%- content %></div>
<script type="text/javascript">
  window.__INITIAL__STOTE__ = <%%- initialStore %>
</script>
</body>
</html>
